package 面试常见刷题;

import java.util.Arrays;

public class 快速排序 {
    public static void main(String[] args) {
        int[] ints = {1, 213, 12, 31, 41, 12};
        subQuickSort(ints,0,5);
        System.out.println(Arrays.toString(ints));

    }
    public static void subQuickSort(int[] values,int start, int end){
        if(start>end) return;
        int temp = values[start];
        int i=start,j=end;
        while (i<j){
            while (values[j]>=temp && i<j){
                j--;
            }
            while (values[i]<=temp &&i<j){
                i++;
            }
            if(i<j){
                int p =values[i];
                values[i] = values[j];
                values[j] = p;
            }
        }
        values[start] = values[i];
        values[i] = temp;
        subQuickSort(values,start,i-1);
        subQuickSort(values,i+1,end);
    }
}
